﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Configuration;

namespace WPP_Console
{
    /// <summary>
    /// Interaction logic for PrintSettingsWindow.xaml
    /// </summary>
    public partial class PrintSettingsWindow : Window
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public PrintSettingsWindow()
        {
            InitializeComponent();

            // Gets a list of installed printers and adds 
            foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                comboBox1.Items.Add(printer);
            }
        }

        /// <summary>
        /// Click handler for the Cancel button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// Click handler for the Save button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (comboBox1.SelectedIndex == -1)
            {
                MessageBox.Show("Please make a selection. Also ensure that your selection is a printer running Zebra label printer drivers.");
                return;
            }
            if (comboBox1.SelectedIndex >= 0) ConfigurationManager.AppSettings["printer_name"] = comboBox1.SelectedItem.ToString();
            MessageBox.Show(ConfigurationManager.AppSettings["printer_name"].ToString());
            this.Close();
        }
    }
}
